package com.shrct.businessprocess.customerservice.impl;

import com.shrct.businessprocess.customerservice.RCFaultStatus;
import com.shrct.businessprocess.customerservice.RCFaultWorkItem;
import com.shrct.businessprocess.customerservice.RCFaultWorkItemCriteria;
import com.shrct.businessprocess.organization.RCEmployee;
import edu.fudan.mylang.pf.query.HQLBasedPagedQueryCriteria;
import java.util.Collection;
import java.util.Date;
import org.hibernate.Query;

public class RCFaultWorkItemCriteriaImpl extends HQLBasedPagedQueryCriteria<RCFaultWorkItem> implements RCFaultWorkItemCriteria {
  private RCEmployee worker;
  
  public RCEmployee getWorker() {
    return this.worker;
  }
  
  public RCFaultWorkItemCriteria setWorker(final RCEmployee worker) {
    this.worker = worker;
    return this;			
    
  }
  
  private Date assignDateFrom;
  
  public Date getAssignDateFrom() {
    return this.assignDateFrom;
  }
  
  public RCFaultWorkItemCriteria setAssignDateFrom(final Date assignDateFrom) {
    this.assignDateFrom = assignDateFrom;
    return this;			
    
  }
  
  private Date assignDateTo;
  
  public Date getAssignDateTo() {
    return this.assignDateTo;
  }
  
  public RCFaultWorkItemCriteria setAssignDateTo(final Date assignDateTo) {
    this.assignDateTo = assignDateTo;
    return this;			
    
  }
  
  private String sid;
  
  public String getSid() {
    return this.sid;
  }
  
  public RCFaultWorkItemCriteria setSid(final String sid) {
    this.sid = sid;
    return this;			
    
  }
  
  private Collection<RCFaultStatus> status;
  
  public Collection<RCFaultStatus> getStatus() {
    return this.status;
  }
  
  public RCFaultWorkItemCriteria setStatus(final Collection<RCFaultStatus> status) {
    this.status = status;
    return this;			
    
  }
  
  private Boolean marked;
  
  public Boolean getMarked() {
    return this.marked;
  }
  
  public RCFaultWorkItemCriteria setMarked(final Boolean marked) {
    this.marked = marked;
    return this;			
    
  }
  
  protected String buildHQLFrom() {
    return " from com.shrct.businessprocess.customerservice.impl.RCFaultWorkItemImpl this ";
  }
  
  protected String buildHQLBody() {
    String hql = "where 1 = 1 ";
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getWorker()) ){
    	hql += " and ((this.worker) = (:worker))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getAssignDateFrom()) ){
    	hql += " and ((this.assignDate) >= (:assignDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getAssignDateFrom()) ){
    	hql += " and ((this.assignDate) <= (:assignDateFrom))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid()) ){
    	hql += " and (this.faultReport.sid  LIKE :sid)" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus()) ){
    	hql += " and (this.faultReport.status  IN (:status))" ;
    }
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getMarked()) ){
    	hql += " and ((this.faultReport.marked) = (:marked))" ;
    }
    return hql;
    
  }
  
  public void initOrderBys() {
    
  }
  
  protected void fillParameter(final Query query) {
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getWorker())){
    	query.setParameter("worker",getWorker()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getAssignDateFrom())){
    	query.setParameter("assignDateFrom",getAssignDateFrom()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getAssignDateTo())){
    	query.setParameter("assignDateTo",getAssignDateTo()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getSid())){
    	query.setParameter("sid",getSid()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getStatus())){
    	query.setParameterList("status",getStatus()) ;
    }			
    if( !edu.fudan.mylang.pf.query.QueryUtil.isNull(getMarked())){
    	query.setParameter("marked",getMarked()) ;
    }			
    
  }
  
  protected Boolean isDistinct() {
    return false;
  }
  
  public RCFaultWorkItemCriteriaImpl() {
    initOrderBys();
  }
}
